/*
dtim.c
Project 3

Vincent Yee vyee2@asu.edu 1202853946 
Jimmy Nguyen jnguye22@asu.edu 1202701781 

CSE 325 Embedded Microprocessor Systems
Spring 2013
*/

#include "support_common.h" /* include peripheral declarations and more */
#include <stdio.h>
#include "dtim.h"
#include "ledmat.h"

void dtim0_delay()
{
         // resets the counter
	MCF_PIT0_PCSR |= 0x4;
                MCF_DTIM0_DTRR = 0x05DA;
                MCF_DTIM0_DTCN = 0x00000000;
               
                //MCF_DTIM0_DTER |= 0x02;
  
        while ((MCF_DTIM0_DTER & 0x02) != 1)
        {
        	MCF_PIT0_PCSR |= 0x4;
        }
        MCF_DTIM0_DTER |= 0x02;
	
	/*MCF_DTIM0_DTRR = 0x095;
	MCF_DTIM0_DTCN &= 0;
	
	while (((MCF_DTIM0_DTER & ( 1<<1 )) >> 1) != 1)
	{
		//ledmat_refresh();
	}
	MCF_DTIM0_DTER |= (1 << 1);
      */  
        
}
void dtim0_init() // check all numbers. Just changed 0 to 3 for now
{
        MCF_DTIM0_DTMR |= 0xf0b;  
        MCF_DTIM0_DTXMR = 0x00;
        
	
	
/*	MCF_DTIM0_DTMR |= (1<<1);
	MCF_DTIM0_DTMR |= (1<<3);
	MCF_DTIM0_DTMR |= (0xF << 8);
	MCF_DTIM0_DTMR |= 1;
*/	
}

